<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = ["a", "b", "c", "d", "e"];

      const proxyArr = new Proxy(arr, {
        get(target, property) {
          console.log("进入get捕获器");
          // return target[property];
          return Reflect.get(target, property);
        },
        set(target, property, value) {
          console.log("进入set捕获器");
          // target[property] = value;
          return Reflect.set(target, property, value);
        },
        deleteProperty(target, property) {
          console.log("进入delete捕获器");
          // delete target[property];
          return Reflect.deleteProperty(target, property);
        },
      });
      console.log(proxyArr, "proxyArr");

      //获取
      console.log(proxyArr[0]);

      //设置
      // proxyArr[1] = "z";
      // proxyArr.length = 10;
      // proxyArr.push(1);

      //删除
      // proxyArr.length = 0;
      // delete proxyArr[2];
      proxyArr.splice(1, 1);
    </script>
  </body>
</html>
